<?php
// +----------------------------------------------------------------------
// | Description: 商城接口
// +----------------------------------------------------------------------
// | Author: zl
// +----------------------------------------------------------------------

namespace app\crm\controller;

use app\crm\model\Customer as CustomerModel;
use app\mini\model\PersonCustomer;
use app\crm\model\TransferShop;
use app\crm\model\CustomerAccountLog;
use app\services\SendMsg;
use think\facade\Db;
use app\Request;
use think\Env;

class ApiShop
{
    // 处理数据
    public function updateProductIds()
    {
        // 每次处理100条记录，避免内存溢出
        Db::table('xy_product_item')->chunk(100, function ($items) {
            foreach ($items as $item) {
                $productIds = [];
                
                // 解析JSON数据
                if (!empty($item['product_info'])) {
                    $productInfo = json_decode($item['product_info'], true);
                    
                    // 验证JSON解析结果
                    if (is_array($productInfo) && !empty($productInfo)) {
                        foreach ($productInfo as $product) {
                            if (isset($product['id'])) {
                                $productIds[] = $product['id'];
                            }
                        }
                    }
                }
                
                // 将ID数组转换为逗号分隔的字符串
                $productIdsStr = implode(',', $productIds);
                
                // 更新product_ids字段
                Db::table('xy_product_item')
                    ->where('id', $item['id'])
                    ->update([
                        'product_ids' => $productIdsStr,
                        'update_time' => time()  // 可选：同时更新修改时间
                    ]);
            }
        });
    }
    
    
    public function addTypeToProductInfo()
    {
        // 每次处理100条记录
        Db::table('xy_product_item')->chunk(100, function ($items) {
            foreach ($items as $item) {
                if (empty($item['product_info'])) {
                    continue;
                }
                
                $productInfo = json_decode($item['product_info'], true);
                $updated = false;
                
                if (is_array($productInfo)) {
                    foreach ($productInfo as &$product) {
                        // 检查是否已存在type字段，不存在则添加
                        if (!isset($product['type'])) {
                            $product['type'] = 'goods';
                            $updated = true;
                        }
                    }
                    
                    if ($updated) {
                        // 重新编码为JSON
                        $newProductInfo = json_encode($productInfo, JSON_UNESCAPED_UNICODE);
                        
                        // 更新数据库
                        Db::table('xy_product_item')
                            ->where('id', $item['id'])
                            ->update([
                                'product_info' => $newProductInfo,
                                'update_time' => time()
                            ]);
                    }
                }
            }
        });
    }
    
    
    
    // 手机号匹配
    public function miniJoinCrmUser(Request $request)
    {
        $param = $request->param();
        //查询中台系统用户信息
        $crm = Db::name('customer')->alias('c')
        ->field('c.id, c.telephone, c.customer_name, c.birthday, c.create_time, c.is_youjiyun, c.operator, au.realname as creator_name, s.shop_id, s.shop_name, s.shop_type, s.type, s.market_id, c.shop_id, a.point as integral, a.balance, a.gift')
            ->join('shop s', 'c.shop_id = s.shop_id','LEFT')
            ->join('admin_user au', 'c.operator = au.id','LEFT')
            ->join('customer_account a', 'c.id = a.id','LEFT')
            ->where('c.telephone', $param['phone'])
            ->find();
        //如果已经有用户
        if($crm)
        {
            // 更新用户信息
            $update = ['mini_id' => $param['uid']];
            Db::name('customer')->where('id', $crm['id'])->update($update);

            //更新积分信息
            if(!empty($param['integral']))
            {
                $point['point'] = $param['integral']??0;
                $point['all_point'] = $param['integral']??0;
                Db::name('customer_account')->where('id',$crm['id'])->update($point);
            }

            // 组装返回数据
            $crm['is_chuanyu'] = 1;
            $crm['is_show_balance'] = 1;
            $crm['is_show_money'] = true;

            $list['info'] = $crm;

            //返回用户总余额
            $list['balance'] = bcadd((string)$crm['balance'], (string)$crm['gift'], 2);
            $list['shop']['shopName'] = $crm['shop_name'];
            $list['shop']['isShowBalance'] = 1;
            $list['shop']['balanceTotle'] = $list['balance'];
        }else
        {
            $list = [];
        }
        return json(['data'=>$list,'code'=>1]);
    }


    //小红薯 - 注册时 用户ID互通
    public function redJoinCrmUser(Request $request)
    {
        $param = $request->param();
        //查询中台系统用户信息
        $crm = Db::name('customer')->alias('c')
            ->join('shop s', 'c.shop_id = s.shop_id','LEFT')
            ->join('customer_point p', 'c.id = p.customer_id','LEFT')
            ->where('c.telephone', $param['phone'])
            ->column('c.id, s.shop_type, s.type, s.market_id, c.shop_id, p.total');
        //如果已经有用户
        if($crm)
        {
            // 使用自定义排序将type=2的元素移到数组末尾
            usort($crm, function($a, $b) {
                if ($a['type'] == 2 && $b['type'] != 2) {
                    return 1;
                } elseif ($a['type'] != 2 && $b['type'] == 2) {
                    return -1;
                } else {
                    return 0; // 保持原有顺序
                }
            });

            // 第二阶段：处理剩余的记录
            foreach ($crm as $key => $val) {
                $data = [
                    'id'    => $val['id'],
                    'phone' => $param['phone']
                ];

                // 更新用户信息
                $update = ['mini_id' => $param['uid']];
                Db::name('customer')->where('id', $val['id'])->update($update);

                // 获取并处理用户信息
                $customerInfo = $this->getCustomerModel()->getDataInfo($data);

                // 组装返回数据
                $list[$key] = [
                    'info' => array_merge($customerInfo, [
                        'shop_type'   => $val['shop_type'],
                        'type'   => $val['type'],
                        'market_id'   => $val['market_id'],
                        'is_chuanyu'  => in_array($val['market_id'], [8, 9, 10, 11]) ? 1 : 0,
                        'integral'    => $val['total']
                    ]),
                    'shop'    => $this->getPersonCustomer()->getCustomerInfo($data),
                    'balance' => $this->getCustomerModel()->getCustomerBalanceSum($val['id'], $val['shop_id'])
                ];
            }

        }else
        {
            //没有用户 注册用户信息  默认营销中心
            $inser['shop_id'] = 74076159037951;
            $inser['mini_id'] = $param['uid'];
            $inser['telephone'] = $param['phone'];
            $inser['status'] = 1; //正常
            $inser['customer_name'] = $param['nickname'];
            $inser['source_id'] = 52;// 客户来源 小红书
            $inser['operator'] = 2001;// 添加人
            $inser['card_is_correct'] = 1; // 卡项是否正确 0否 1是 (选择是后无法修改)
            $inser['create_time'] = $param['add_time'];
            $md_id = Db::name('customer')->insertGetId($inser);
            //返回用户信息
            $list[0]['info']['id'] = $md_id;
            $list[0]['info']['shop_id'] = 74076159037951;
            $list[0]['info']['shop_type'] = 2;
        }
        return json(['data'=>$list,'code'=>1]);
    }



    //获取用户信息
    public function miniGetUserInfo(Request $request)
    {
        $param = $request->param();
        if(empty($param['phone']))
        {
            return json(['msg'=>'缺少必传参数','code'=>0]);
        }

        $list = [];
         //查询中台系统用户信息
        $crm = Db::name('customer')->alias('c')
        ->field('c.id, c.telephone, c.customer_name, c.birthday, c.create_time, c.is_youjiyun, c.operator, au.realname as creator_name, s.shop_id, s.shop_name, s.shop_type, s.type, s.market_id, c.shop_id, a.point as integral, a.balance, a.gift')
            ->join('shop s', 'c.shop_id = s.shop_id','LEFT')
            ->join('admin_user au', 'c.operator = au.id','LEFT')
            ->join('customer_account a', 'c.id = a.id','LEFT')
            ->where('c.telephone', $param['phone'])
            ->find();
        //如果已经有用户
        if($crm)
        {
            // 组装返回数据
            $crm['is_chuanyu'] = 1;
            $crm['is_show_balance'] = 1;
            $crm['is_shungmei'] = 1;
            $crm['is_show_money'] = true;

            $list['info'] = $crm;

            //返回用户总余额
            $list['balance'] = bcadd((string)$crm['balance'], (string)$crm['gift'], 2);
            $list['shop']['shopName'] = $crm['shop_name'];
            $list['shop']['isShowBalance'] = 1;
            $list['shop']['balanceTotle'] = $list['balance'];
        }
        return json(['data'=>$list,'code'=>1]);
    }



    //获取订单所需信息
    public function miniGetOrderInfo(Request $request)
    {
        $param = $request->param();
        if(empty($param['id']))
        {
            return json(['msg'=>'缺少必传参数','code'=>0]);
        }
        $list = [];
        $crm = Db::name('customer')->alias('c')
            ->join('shop s', 'c.shop_id = s.shop_id','LEFT')
            ->join('customer_point p', 'c.id = p.customer_id','LEFT')
            ->where('c.telephone', $param['phone'])
            ->column('c.id, s.shop_type, s.market_id, c.shop_id, p.total');

        return json(['data'=>$list,'code'=>1]);
    }


    //获取用户余额明细
    public function miniGetUserBalance(Request $request)
    {
        $param = $request->param();
        if(empty($param['id']) || empty($param['shop_id']))
        {
            return json(['msg'=>'缺少必传参数','code'=>0]);
        }
        $list['log'] = $this->getCustomerModel()->getCustomerBalanceLog($param['id'],$param['shop_id'],$param['page'],$param['pagesize']);
        $list['balance'] = $this->getCustomerModel()->getCustomerBalanceSum($param['id'],$param['shop_id']);
        return json(['data'=>$list,'code'=>1]);
    }





    //获取全部门店信息
    public function miniGetShopAll(Request $request)
    {
        $shopList = Db::name('shop')
            ->field('shop_id,shop_name,market_id,type,shop_type,status,start_time,end_time,shop_phone,region_id,shop_mobile,province_name,city_name,country_name,address,longitude,latitude')
            ->where('type', 1)
            ->where('status', 1)
            ->select()
            ->toArray();

        // 遍历结果集，为每条数据添加 is_sm 字段
        foreach ($shopList as &$item)
        {
            $item['is_sm'] = 1; // 添加字段并赋值
        }
        unset($item); // 解除引用

        return json(['data' => $shopList, 'code' => 1]);
    }




    //获取单个门店信息
    public function miniGetShopInfo(Request $request)
    {
        $param = $request->param();
        if(empty($param['shop_id']))
        {
            return json(['msg'=>'缺少必传参数','code'=>0]);
        }
        $shop = Db::name('shop')->where('shop_id',$param['shop_id'])->find();

        return json(['data'=>$shop,'code'=>1]);
    }


    //获取商品信息
    public function miniGetGoodsInfo(Request $request)
    {
        $param = $request->param();

        $where = [];
        if(!empty($param['search']))
        {
            $where[] = ['g.name','like','%' .$param['search'].'%'];//商品名称搜索

        }elseif(!empty($param['goods_id']))
        {
            $where[] = ['g.id','=',$param['goods_id']];//商品ID搜索
        }

        $goods = Db::name('shop_goods')
            ->alias('g')
            ->join('shop_goods_category c', 'g.category_id = c.id')
            ->where($where)
            ->where('g.delete_time', 0)
            ->field('g.*, c.name as category_name')
            ->select();
        $list['goods'] = $goods;
        // $list['point'] = Db::name('')
        return json(['data'=>$goods,'code'=>1]);
    }



    //获取疗程卡
    public function miniGetUserService(Request $request)
    {
        $param = $request->param();
        if(empty($param['id']))
        {
            return json(['msg'=>'缺少必传参数','code'=>0]);
        }
        //查询条件
        $where = [];
        array_push($where,['status','=','1']);
        array_push($where,['customer_id','=',$param['id']]);
        //总数
        $serviceList = Db::name('service')
        ->where($where)
        ->select()
        ->toArray();
        if(!empty($serviceList))
        {
            foreach($serviceList as &$v)
            {
                $v['service_type'] = $v['service_type'] == 1 ? '疗程卡' : '次卡';
                $v['useNumber'] = Db::name('service_log')->where('service_id',$v['id'])->where('deleted_at','=',0)->count();
                $name = DB::name('shop_order_goods')->where('order_id',$v['order_id'])->where('goods_id',$v['goods_id'])->value('goods_alias_name');
                $v['name'] = !empty($name)?$name:$v['name'];

                if($v['customer_activity_id']>0)
                {
                    $v['start_time'] = $v['use_begin_time']>0 ? date("Y-m-d",$v['use_begin_time']) : '';
                   $v['end_time'] = $v['use_end_time']>0 ? date("Y-m-d",$v['use_end_time']) : '';
                }else{
                   $v['start_time'] = $v['start_time']>0 ? date("Y-m-d",$v['start_time']) : '';
                    $v['end_time'] = $v['end_time']>0 ? date("Y-m-d",$v['end_time']) : '';
                }
            }
            // 解除引用绑定
            unset($v);
        }
        return json(['data'=>$serviceList,'code'=>1]);
    }


    //商城积分变动
    public function miniUpdatePoint(Request $request)
    {
        $param = $request->param();
        // 参数验证
        if (empty($param['sm_id']) || empty($param['number']))
        {
            return json(['msg'=>'缺少必传参数','code'=>0]);
        }

        // 数值验证
        $param['sm_id'] = (int)$param['sm_id'];
        $param['number'] = bcadd($param['number'], 0, 2); // 转换为高精度数值

        // 查询所有积分LOG存储类型
        $setting = Db::name('setting')->where('category_id', 18)->column('id', 'name');

        // 获取当前积分值
        $point = Db::name('customer_account')->where('id', $param['sm_id'])->value('point');

        if ($point === null)
        {
            return json(['msg'=>'找不到用户账户','code'=>0]);
        }

        // 准备日志数据
        $remarks = $param['title'] ?? '积分变更';
        $notes = $setting[$param['title']] ?? 720;
        // 积分增加操作
        if ($param['pm'] == 1)
        {
            $symbol = 1;

            // 现有积分
            Db::name('customer_account')
                ->where('id', $param['sm_id'])
                ->inc('point', $param['number'])
                ->update();

            // 累计积分
            Db::name('customer_account')
                ->where('id', $param['sm_id'])
                ->inc('all_point', $param['number'])
                ->update();
        }elseif ($param['pm'] == 0)// 积分减少操作
        {
            $symbol = 2;

            // 验证积分是否足够
            if (bccomp($point, $param['number'], 2) < 0)
            {
                return json(['msg'=>"积分不足: 当前 {$point}，需要 {$param['number']}",'code'=>0]);
            }

            // 现有积分
            Db::name('customer_account')
                ->where('id', $param['sm_id'])
                ->dec('point', $param['number'])
                ->update();

            // 累计积分
            Db::name('customer_account')
                ->where('id', $param['sm_id'])
                ->dec('minus_point', $param['number'])
                ->update();
        }

        // 计算新积分值
        $newPoint = ($param['pm'] == 1) ? bcadd($point, $param['number'], 2) : bcsub($point, $param['number'], 2);

        // 增加积分流水LOG
        $log = [
            'customer_id' => $param['sm_id'],
            'last_amount'  => $point,
            'amount'  => $param['number'],
            'now_amount'  => $newPoint,
            'symbol' => $symbol,
            'type' => 1,
            'notes' => $notes,
            'remarks' => $remarks,
            'create_time' => time()
        ];

        // 添加积分日志
        $res = Db::name('customer_account_log')->insertGetId($log);

        if (!$res)
        {
            return json(['msg'=>'积分日志记录失败','code'=>0]);
        }

        return json(['data'=>'','code'=>1]);
    }


    // 获取优惠券总数量
    public function miniCouponProvideCount(Request $request)
    {
        // 获取请求参数
        $param = $request->param();

        // 参数验证
        if (empty($param['id'])) {
            return json(['msg' => '缺少必传参数用户ID', 'code' => 0]);
        }

        // 构建基本查询条件
        $where = [];
        $where[] = ['customer_id', '=', $param['id']];

        $list = [];
        $list['weishiyong'] = Db::name('coupon_provide_customer')->where($where)->where('staus',0)->count() ?? 0;
        $list['yishiyong'] = Db::name('coupon_provide_customer')->where($where)->where('staus',1)->count() ?? 0;
        $list['yishixiao'] = Db::name('coupon_provide_customer')->where($where)->where('staus',2)->count() ?? 0;

        return json(['data'=>$list,'code'=>1]);
    }



    // 获取用户优惠券列表
    public function miniCouponProvide(Request $request)
    {
        // 获取请求参数
        $param = $request->param();

        // 参数验证
        if (empty($param['id'])) {
            return json(['msg' => '缺少必传参数用户ID', 'code' => 0]);
        }

        // 设置分页参数（从请求中获取或使用默认值）
        $page = isset($param['page']) ? max(1, (int)$param['page']) : 1;
        $pageSize = isset($param['pagesize']) ? max(1, (int)$param['pagesize']) : 10;

        // 构建基本查询条件
        $where = [];
        $where[] = ['customer_id', '=', $param['id']];

        // 添加状态筛选条件 - 使用原字段名staus
        if (!empty($param['status'])) {
            $where[] = ['staus', '=', $param['status']];
        }

        // 获取当前时间
        $currentTime = time();

        // 查询用户持有的优惠券 - 添加分页
        $paginator = Db::name('coupon_provide_customer')
            ->where($where)
            ->order('id', 'desc') // 建议添加排序
            ->paginate([
                'list_rows' => $pageSize,
                'page' => $page,
                'query' => request()->param()
            ]);

        // 获取分页数据和用户优惠券列表
        $pageData = $paginator->toArray();
        $userCoupons = $pageData['data'];

        if (empty($userCoupons)) {
            return json([
                'code' => 1,
                'data' => [
                    'data' => [],
                    'total' => 0,
                    'current_page' => $page,
                    'last_page' => 1
                ]
            ]);
        }

        // 获取所有优惠券ID
        $couponIds = array_column($userCoupons, 'coupon_id');

        // 查询优惠券详细信息
        $couponFields = [
            'id', 'name', 'use_type', 'type', 'use_threshold',
            'denomination', 'start_time', 'end_time', 'status'
        ];

        $coupons = Db::name('coupon')
            ->where('id', 'in', $couponIds)
            ->column($couponFields, 'id');

        // 优惠券类型映射
        $typeNames = [
            1 => '满减券',
            2 => '满赠券',
            3 => '兑换券'
        ];

        // 处理结果集
        $result = [];

        foreach ($userCoupons as $coupon)
        {
            $couponId = $coupon['coupon_id'];

            // 跳过不存在的优惠券
            if (!isset($coupons[$couponId])) continue;

            $couponInfo = $coupons[$couponId];
            $item = $coupon;

            // 状态判断 - 使用原字段名staus
            if ($coupon['staus'] == 1) {
                $status = 1; // 已使用
            } elseif ($couponInfo['end_time'] < $currentTime) {
                $status = 4; // 已过期
            } elseif ($couponInfo['start_time'] > $currentTime) {
                $status = 3; // 未开始
            } else {
                $status = 2; // 可使用
            }

            // 格式化数据
            $item['status'] = $status;
            $item['name'] = $couponInfo['name'] ?? '';
            $item['use_type'] = $couponInfo['use_type'] ?? 0;
            $item['use_threshold'] = $couponInfo['use_threshold'] ?? 0;
            $item['denomination'] = $couponInfo['denomination'] ?? 0;
            $item['start_time'] = $couponInfo['start_time']
                ? date('Y-m-d H:i:s', $couponInfo['start_time'])
                : '';
            $item['end_time'] = $couponInfo['end_time']
                ? date('Y-m-d H:i:s', $couponInfo['end_time'])
                : '';
            $item['create_time'] = $coupon['create_time']
                ? date('Y-m-d H:i:s', $coupon['create_time'])
                : '';
            $item['use_time'] = $coupon['use_time']
                ? date('Y-m-d H:i:s', $coupon['use_time'])
                : '未使用';
            $item['endTimeT'] = $couponInfo['end_time'] ?? 0;
            $item['type'] = $couponInfo['type'] ?? 0;
            $item['type_name'] = $typeNames[$item['type']] ?? '未知类型';

            $result[] = $item;
        }

        // 返回分页结果
        return json([
            'code' => 1,
            'data' => [
                'data' => $result,
                'total' => $pageData['total'],
                'per_page' => $pageSize,
                'current_page' => $page,
                'last_page' => $pageData['last_page']
            ]
        ]);

    }





    // 获取双美前置店铺信息
    public function shuangmeiShop()
    {
        $shop = [];
        $shop = Db::name('shop')->where('status',1)->column('shop_id,market_id,shop_name,address,shop_phone');
        return json(['data'=>$shop,'code'=>1]);
    }

    //中台系统查询双美有无用户信息
    public function checkPhoen(Request $request)
    {
        $param = $request->param();
        $list = Db::name('customer')->where('telephone', $param['phone'])->count();
        return json(['data'=>$list,'code'=>1]);
    }

    //中台系统查询双美有无该客服信息
    public function checkAdminUser(Request $request)
    {
        $param = $request->param();
        $list = Db::name('admin_user')->where('mobile', $param['phone'])->where('status',1)->value('id');
        return json(['data'=>$list,'code'=>1]);
    }
    
    // 中台系统查询双美来源信息
    public function checkSourceId(Request $request)
    {
        $param = $request->param();
        $source = Db::name('setting')->where('name',$param['name'])->where('category_id',$param['category_id'])->value('id');
        return json(['data'=>$source,'code'=>1]);
    }

    //中台用户录入到中台系统
    public function insertCrmCustomer(Request $request)
    {
        $param = $request->param();
        $customerId = Db::name('customer')->insertGetId($param);

        if(!$customerId)
        {
            return json(['msg' => '添加失败', 'code' => 0]);
        }

        // 存储客户的余额信息 - 默认都为0
        $customer_account['id'] =$customerId;
        $check_account = Db::name('customer_account')->where('id',$customerId)->count();
        if($check_account < 1)
        {
            Db::name('customer_account')->insert($customer_account);
        }

        // 存储客户的其他信息
        $customer_info['id'] =$customerId;
        $check_info = Db::name('customer_info')->where('id',$customerId)->count();
        if($check_info < 1)
        {
            Db::name('customer_info')->insert($customer_info);
        }
        return json(['msg' => '添加成功', 'data' => $customerId, 'code' => 1]);
    }

    
    
    
    // 中台系统调用公众号粉丝查询
    public function smGzhFans(Request $request)
    {
        $param = $request->param();
        $openid = '';
        $unionId = DB::name('mini_program_fans')->where('telephone',$param['phone'])->value('unionId');
        if(!empty($unionId)){
            $openid = DB::name('wx_gzh_fans')->where('unionid',$unionId)->value('openid');
        }
        return json(['msg' => '获取成功', 'data' => $openid, 'code' => 200]);
    }
    

    // 测试短信
    public function sendSMS(Request $request)
    {
        $param = $request->param();
        // 实例化类
        $sendMsg = new SendMsg();
        // 调用方法

        // $rand = rand(100000,999999);
        // 单个调用
        // $data = [
        //     'market_id' => 1,
        //     'shop_id' => 85038462412521,
        //     'customer_id' => 38,
        //     'telephone' => '13621205223',
        //     'content' => '【欣奕除疤】您的验证码是'. $rand .'。如非本人操作，请忽略本短信',
        //     'type' => 2,
        // ];
        // $result = $sendMsg->sendSMS($data);

        // 多个调用
        $dataList = [
        [
            'market_id' => 1,
            'shop_id' => 85038462412521,
            'customer_id' => 1,
            'telephone' => '13298416962',
            'content' => '【欣奕除疤】您的验证码是'. rand(100000,999999) .'。如非本人操作，请忽略本短信',
        ],
        [
            'market_id' => 1,
            'shop_id' => 85038462412521,
            'customer_id' => 2,
            'telephone' => '13298416962',
            'content' => '【欣奕除疤】您的验证码是'. rand(100000,999999) .'。如非本人操作，请忽略本短信',
        ]
    ];

        $result = $sendMsg->sendBatchSMS($dataList);
        return json(['msg' => $result['msg'], 'code' => $result['code']]);
    }

    // 注册序列号
    public function registEx(Request $request)
    {
        $param = $request->param();

        // 实例化类
        $sendMsg = new SendMsg();
        $result = $sendMsg->registEx();
        return json(['msg' => $result['msg'], 'code' => $result['code']]);
    }

    // 查询余额
    public function getBalance(Request $request)
    {
        $param = $request->param();

        // 实例化类
        $sendMsg = new SendMsg();
        $result = $sendMsg->getBalance();
        return json(['msg' => $result['msg'], 'data' => $result['data'], 'code' => $result['code']]);
    }

    protected function getCustomerModel()
    {
        return new CustomerModel();
    }
    protected function getPersonCustomer()
    {
        return new PersonCustomer();
    }
    protected function getCustomerAccountLog()
    {
        return new CustomerAccountLog();
    }
}
